﻿<UserControl x:Class="StockAnalyst2.Plugins.Visualization.Historical.DetailViewer"
			 x:ClassModifier="internal"
			 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 mc:Ignorable="d" 
			 
             xmlns:Converters="clr-namespace:StockAnalyst2.Converters"
             xmlns:ConvertersGeneric="clr-namespace:Utils.Wpf.Converters;assembly=Utils"
             xmlns:Historical="clr-namespace:StockAnalyst2.Plugins.Visualization.Historical" 
			 
			 Background="#1F1F1F" 
			 
			 LayoutUpdated="UserControl_LayoutUpdated"
			 
             d:DataContext="{d:DesignInstance Type=Historical:DetailViewerVM}" 
			 d:DesignWidth="1000" >

	<UserControl.Resources>
		<ResourceDictionary>
			<Converters:PositiveGreenNegativeRedConverter x:Key="PositiveGreenNegativeRedConverter" />
			<ConvertersGeneric:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
			<ConvertersGeneric:NegatedBooleanToVisibilityConverter x:Key="NegatedBooleanToVisibilityConverter" />
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="..\..\..\StockAnalystTheme.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>

	<Expander IsExpanded="False">
		<Expander.HeaderTemplate>
			<DataTemplate>
				<TextBlock Foreground="{StaticResource FontBrush}" Text="Operations" FontWeight="Bold" Margin="9,3,3,3" />
			</DataTemplate>
		</Expander.HeaderTemplate>
		<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Rows}" Background="{StaticResource GridBackground}" RowBackground="{StaticResource GridBackground}" HorizontalGridLinesBrush="{StaticResource SelectedRowBrush}" VerticalGridLinesBrush="{StaticResource DataGridHeaderBorderBrush}" RowHeaderWidth="0" HeadersVisibility="All" Foreground="{StaticResource FontBrush}" BorderThickness="0" SelectionMode="Extended" Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type Historical:DetailViewer}}}" IsManipulationEnabled="False" d:DataContext="{d:DesignInstance Historical:DetailViewerRowVM}" >
			<DataGrid.Resources>
				<Style TargetType="FrameworkElement" x:Key="TextMargin" >
					<Setter Property="Margin" Value="10,0,10,0" />
					<Setter Property="HorizontalAlignment" Value="Right" />
				</Style>
			</DataGrid.Resources>
			<DataGrid.ContextMenu>
				<ContextMenu>
					<MenuItem Command="Copy" >
						<MenuItem.Icon>
							<Image Source="..\..\..\Resources\Copy.ico" Stretch="None" />
						</MenuItem.Icon>
					</MenuItem>
					<MenuItem Command="SelectAll">
						<MenuItem.Icon>
							<Image Source="..\..\..\Resources\SelectAll.ico" Stretch="None" />
						</MenuItem.Icon>
					</MenuItem>
				</ContextMenu>
			</DataGrid.ContextMenu>
			<DataGrid.Columns>
				<DataGridTemplateColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" CanUserReorder="False" >
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal" >
								<Image Source="..\..\..\Resources\Long.ico" Visibility="{Binding IsLongOperation, Converter={StaticResource BooleanToVisibilityConverter}, FallbackValue=Collapsed}" Stretch="None" />
								<Image Source="..\..\..\Resources\Short.ico" Visibility="{Binding IsLongOperation, Converter={StaticResource NegatedBooleanToVisibilityConverter}, FallbackValue=Collapsed}" Stretch="None" />
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderLeft}" CanUserResize="False" IsReadOnly="True" Header="Operation Start" Binding="{Binding OpeningDate, StringFormat=dd/MM/yyyy&#160;HH\\:mm\\:ss}" CanUserReorder="False" x:Name="OperationStartColumn" />
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderLeft}" CanUserResize="False" IsReadOnly="True" Header="Operation Close" Binding="{Binding ClosingDate, StringFormat=dd/MM/yyyy&#160;HH\\:mm\\:ss}" CanUserReorder="False" x:Name="OperationEndColumn" />
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderLeft}" CanUserResize="False" IsReadOnly="True" Header="Duration" Binding="{Binding Duration, StringFormat=hh\\:mm\\:ss}" CanUserReorder="False" x:Name="DurationColumn" >
					<DataGridTextColumn.ElementStyle>
						<Style TargetType="{x:Type TextBlock}">
							<Setter Property="Margin" Value="10,0,10,0" />
							<Setter Property="HorizontalAlignment" Value="Center" />
						</Style>
					</DataGridTextColumn.ElementStyle>
				</DataGridTextColumn>
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Buy Value (pt)" Binding="{Binding BuyPrice}" ElementStyle="{StaticResource TextMargin}" CanUserReorder="False" x:Name="BuyPriceColumn" />
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Sell Value (pt)" Binding="{Binding SellPrice}" ElementStyle="{StaticResource TextMargin}" CanUserReorder="False" x:Name="SellPriceColumn" />
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Volume" Binding="{Binding Volume}" ElementStyle="{StaticResource TextMargin}" CanUserReorder="False" x:Name="VolumeColumn" />
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Fee (€)" Binding="{Binding Fee}" ElementStyle="{StaticResource TextMargin}" CanUserReorder="False" x:Name="FeeColumn" />
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Gross Result (pt)" Binding="{Binding GrossResult}"  CanUserReorder="False" x:Name="GrossResultColumn" >
					<DataGridTextColumn.ElementStyle>
						<Style TargetType="{x:Type TextBlock}">
							<Setter Property="Foreground" Value="{Binding GrossResult, Converter={StaticResource PositiveGreenNegativeRedConverter}}" />
							<Setter Property="Margin" Value="10,0,10,0" />
							<Setter Property="HorizontalAlignment" Value="Right" />
						</Style>
					</DataGridTextColumn.ElementStyle>
				</DataGridTextColumn>
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Result (€)" Binding="{Binding Result}"  CanUserReorder="False" x:Name="ResultColumn" >
					<DataGridTextColumn.ElementStyle>
						<Style TargetType="{x:Type TextBlock}">
							<Setter Property="Foreground" Value="{Binding Result, Converter={StaticResource PositiveGreenNegativeRedConverter}}" />
							<Setter Property="Margin" Value="10,0,10,0" />
							<Setter Property="HorizontalAlignment" Value="Right" />
						</Style>
					</DataGridTextColumn.ElementStyle>
				</DataGridTextColumn>
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Result (%)" Binding="{Binding ResultPercentage}"  CanUserReorder="False" x:Name="ResultPercentageColumn" >
					<DataGridTextColumn.ElementStyle>
						<Style TargetType="{x:Type TextBlock}">
							<Setter Property="Foreground" Value="{Binding ResultPercentage, Converter={StaticResource PositiveGreenNegativeRedConverter}}" />
							<Setter Property="Margin" Value="10,0,10,0" />
							<Setter Property="HorizontalAlignment" Value="Right" />
						</Style>
					</DataGridTextColumn.ElementStyle>
				</DataGridTextColumn>
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Result Without Fees (%)" Binding="{Binding ResultPercentageWithoutFees}"  CanUserReorder="False" x:Name="ResultPercentageWithoutFeesColumn" >
					<DataGridTextColumn.ElementStyle>
						<Style TargetType="{x:Type TextBlock}">
							<Setter Property="Foreground" Value="{Binding ResultPercentageWithoutFees, Converter={StaticResource PositiveGreenNegativeRedConverter}}" />
							<Setter Property="Margin" Value="10,0,10,0" />
							<Setter Property="HorizontalAlignment" Value="Right" />
						</Style>
					</DataGridTextColumn.ElementStyle>
				</DataGridTextColumn>
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Accumulated Result (€)" Binding="{Binding AccummulatedResult}"  CanUserReorder="False" x:Name="AccumulatedResultColumn" >
					<DataGridTextColumn.ElementStyle>
						<Style TargetType="{x:Type TextBlock}">
							<Setter Property="Foreground" Value="{Binding ResultPercentageWithoutFees, Converter={StaticResource PositiveGreenNegativeRedConverter}}" />
							<Setter Property="Margin" Value="10,0,10,0" />
							<Setter Property="HorizontalAlignment" Value="Right" />
						</Style>
					</DataGridTextColumn.ElementStyle>
				</DataGridTextColumn>
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Amount Required (€)" Binding="{Binding PartialAmountRequired}" ElementStyle="{StaticResource TextMargin}" CanUserReorder="False" x:Name="AmountRequiredColumn" />
				<DataGridTextColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Total Amount Required (€)" Binding="{Binding TotalAmountRequired}" ElementStyle="{StaticResource TextMargin}" CanUserReorder="False" x:Name="TotalAmountRequiredColumn" Width="*" />
				<!--<DataGridTemplateColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Result" CanUserReorder="False" x:Name="ResultColumn" >
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock HorizontalAlignment="Right" Text="{Binding Result}"  Foreground="{Binding Result, Converter={StaticResource PositiveGreenNegativeRedConverter}}" Style="{StaticResource TextMargin}" />
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>-->
				<!--<DataGridTemplateColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Result(%)" CanUserReorder="False" x:Name="ResultPercentageColumn" >
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
								<TextBlock HorizontalAlignment="Right" Text="{Binding ResultPercentage}"  Foreground="{Binding ResultPercentage, Converter={StaticResource PositiveGreenNegativeRedConverter}}" />
								<TextBlock HorizontalAlignment="Right" Text="%" Margin="6,0,3,0" />
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>-->
				<!--<DataGridTemplateColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Result Without Fees(%)" CanUserReorder="False" x:Name="ResultPercentageWithoutFeesColumn" >
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
								<TextBlock HorizontalAlignment="Right" Text="{Binding ResultPercentageWithoutFees}"  Foreground="{Binding ResultPercentageWithoutFees, Converter={StaticResource PositiveGreenNegativeRedConverter}}" />
								<TextBlock HorizontalAlignment="Right" Text="%" Margin="6,0,3,0" />
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>-->
				<!--<DataGridTemplateColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderRight}" CanUserResize="False" IsReadOnly="True" Header="Accumulated Result" CanUserReorder="False" Width="SizeToHeader" x:Name="AccumulatedResultColumn"  >
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock HorizontalAlignment="Right" Text="{Binding AccummulatedResult}"  Foreground="{Binding AccummulatedResult, Converter={StaticResource PositiveGreenNegativeRedConverter}}" Style="{StaticResource TextMargin}" />
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>-->

				<!--<DataGridTemplateColumn CellStyle="{StaticResource CellSelectionStyle}" HeaderStyle="{StaticResource DataGridColumnHeaderLeft}" CanUserResize="False" IsReadOnly="True" Header="Total Amount Required" CanUserReorder="False" x:Name="TotalAmountRequiredColumn" Width="*" >
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel HorizontalAlignment="Left" Margin="10,0,10,0" Orientation="Horizontal" >
								<TextBlock Text="{Binding TotalAmountRequired}" />
								<TextBlock Text="€" Margin="6,0,0,0" />
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>-->
			</DataGrid.Columns>
		</DataGrid>
	</Expander>
</UserControl>
